package d0524_io案例;

import java.util.Date;

/**
 * Not Serializable Exception
 * 未来   序列化	异常
 * 
 * 被存储到文件中的对象必须实现序列化接口
 * 
 * 序列化: 将数据转换成字节的过程
 * 反序列化: 将字节数据转换回对象
 * 
 * 学生类实现排序接口 Comparable
 * 
 */
public class Student implements java.io.Serializable, Comparable<Student>{
	
	@Override
	public int compareTo(Student o)  {
		return this.sn.compareTo(o.sn);
	}

	
	/**
	 * 序列化版本编号
	 */
	private static final long serialVersionUID = 1L;

	private String sn; 

	private String name;
	
	private Date birthday;
	
	private String qq;
	
	public Student() {
		// 无参数构造函数
		// JavaBean 规范
	}
	
	public Student(String sn, String name, Date birthday, String qq) {
		super();
		this.sn = sn;
		this.name = name;
		this.birthday = birthday;
		this.qq = qq;
	}

	public String getSn() {
		return sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public String getQq() {
		return qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	@Override
	public String toString() {
		return "Student [sn=" + sn + ", name=" + name + ", birthday=" + birthday + ", qq=" + qq + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((birthday == null) ? 0 : birthday.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((qq == null) ? 0 : qq.hashCode());
		result = prime * result + ((sn == null) ? 0 : sn.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Student other = (Student) obj;
		if (birthday == null) {
			if (other.birthday != null)
				return false;
		} else if (!birthday.equals(other.birthday))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (qq == null) {
			if (other.qq != null)
				return false;
		} else if (!qq.equals(other.qq))
			return false;
		if (sn == null) {
			if (other.sn != null)
				return false;
		} else if (!sn.equals(other.sn))
			return false;
		return true;
	}
	
	
	public static void main(String[] args) {
		
		long t = System.currentTimeMillis();
		t -= 1000l * 60l * 60l * 24l * 365l;
		java.util.Date d = new java.util.Date(t);
		System.out.println(t +"   " + d);
		
		
	}


}
